import request from '@/utils/request'

// 订单详细
/**
 *
 * @param {*} mode 状态 cart || buyNow
 * @param {*} obj cart => cartIds ||
 *                buyNow => goodsId,goodsNum,goodsSkuId
 * @returns
 */
export const checkOrder = (mode, obj) => {
  return request.get('/checkout/order', {
    params: {
      mode, // 状态 cart buyNow
      delivery: 10, // 快递方式 10快递配送， 20上门自取
      payType: 10, // 支付方式
      couponId: 0, // 优惠券id  0不使用
      isUsePoints: 0, // 优惠券id  0部使用
      ...obj
    }
  })
}

// 提交订单
/**
 *
 * @param {*} mode 状态 cart || buyNow
 * @param {*} obj cart => obj={ cartIds,remark }  ||
 *                buyNow => obj = { goodsId,goodsNum,goodsSkuId ,remark }
 * @returns
 */
export const submitOrder = (mode, obj) => {
  return request.post('/checkout/submit', {
    mode,
    delivery: 10,
    couponId: 0,
    isUsePoints: 0,
    payType: 10,
    ...obj
  })
}

// 我的订单
/**
 *
 * @param {*} dataType 订单类型，all-全部，payment-待支付，delivery-待发货，received-待收货，comment-待评价
 * @param {*} page 页数 String
 * @returns
 */
export const getMyOrderList = (dataType, page) => {
  return request.get('/order/list', {
    params: {
      dataType,
      page
    }
  })
}
